<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>键盘事件</title>
</head>

<body>
    <script>
        // 执行顺序 keydown  keypress  keyup
        // keyup 按键弹起时触发

        //  传统方法keyup要加on
        // document.onkeyup = function() {
        //     console.log('我叹气来了');
        // }
        document.addEventListener('keyup', function () {
            console.log('我叹气了');
        })
        //  keypress 按键按下时触发
        document.addEventListener('keypress', function () {
            console.log('我叹气');
        })
        // keydown 按键按下时触发
        document.addEventListener('keydown', function () {
            console.log('我');
        }) 
    </script>
</body>

</html>